<?php

Class Hm_Controller_Plugin_Common Extends Zend_Controller_Plugin_Abstract
{
	// route结束时
    public function routeShutdown(Zend_Controller_Request_Abstract $request)
    {
        $module = $request->getModuleName();
        // bootstrap类
        $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');

        //为不同模块指定错误控制器
        $errorHandler = Zend_Controller_Front::getInstance()->getPlugin('Zend_Controller_Plugin_ErrorHandler');
        $errorHandler->setErrorHandlerModule($module);

        // 加载view
        $bootstrap->bootstrap('View');
        $view = $bootstrap->getResource('View');
        $moduleParams = $view->$module;

        // 配置view
        $view->addBasePath($moduleParams['basePath'])
             ->addHelperPath($moduleParams['helperPath'],
                             $moduleParams['helperPathPrefix']);

        // 加载layout并配置
        $bootstrap->bootstrap('Layout');
        $layout = $bootstrap->getResource('Layout');
        $layout->setLayoutPath($moduleParams['layoutPath'])
               ->setLayout($moduleParams['layout']);
    }

}